package main.java.DMDE.controllers;

import java.util.List;

import main.java.DMDE.infrastructure.IProjectContext;
import main.java.DMDE.model.Parameter;
import main.java.DMDE.model.Type;
import main.java.DMDE.view.IParameterView;

public class ParameterController extends BaseController implements IParameterController {

    private IParameterView paramView;

    public ParameterController(IProjectContext projectContext, IParameterView paramView) {
	super(projectContext);
	this.paramView = paramView;
	this.paramView.setController(this);
    }

    @Override
    public Parameter addParameter() {
	
	String paramName = paramView.getName();
	Type paramType = paramView.getType();
	Parameter param = new Parameter(paramType,paramName);
	return param;
    }
    
    @Override
    public Parameter editParameter(Parameter param) {
	String paramName = paramView.getName();
	if (paramName.equals("")) 
	    return null;
	param.setName(paramView.getName());
	param.setType(paramView.getType());
	return param;
    }
    @Override
    public IParameterView getParameterView() {
	return paramView;
    }
    	
    @Override
    public List<Parameter> getParameters() {
	return paramView.getParameters();
    }

}
